home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / CMPLTPAS / KEYTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1988-07-24  |  3KB  |  77 lines

  1. {--------------------------------------------------------------}
  2. {                           KeyTest                            }
  3. {                                                              }
  4. {         Full keyboard access demonstration program           }
  5. {                                                              }
  6. {                             by Jeff Duntemann                }
  7. {                             Turbo Pascal V4.0                }
  8. {                             Last update 7/1/88               }
  9. {                                                              }
  10. {     From: COMPLETE TURBO PASCAL 5.0  by Jeff Duntemann       }
  11. {    Scott, Foresman & Co., Inc. 1988   ISBN 0-673-38355-5     }
  12. {--------------------------------------------------------------}
  13.  
  14. PROGRAM KeyTest;
  15.  
  16. USES Crt,DOS;
  17.  
  18. VAR Ch : Char;
  19.     Extended : Boolean;
  20.     Scan,Shifts : Byte;
  21.     Ready : Boolean;
  22.  
  23. {$I FLUSHKEY.SRC }
  24. {$I GETKEY.SRC }
  25. {$I CURSOFF.SRC }
  26.  
  27. BEGIN
  28.   Ch := ' ';
  29.   Ready := False;
  30.   ClrScr;
  31.   CursorOff;  { Get the cursor out of the way; we don't need it. }
  32.   GotoXY(20,1); Write('< COMPLETE TURBO PASCAL Keyboard Read Demo >');
  33.   GotoXY(30,2); Write('(Press ESC to exit...)');
  34.  
  35.   { First we set up the labels for the shift keys: }
  36.   GotoXY(12,17); Write('Ctrl: ');
  37.   GotoXY(5,18);  Write('Left Shift: ');
  38.   GotoXY(48,18); Write('Right Shift: ');
  39.   GotoXY(13,19); Write('Alt: ');
  40.  
  41.   { Here we set up the labels for the toggle keys: }
  42.   GotoXY(50,19); Write('Caps Lock: ');
  43.   GotoXY(64,19); Write('Insert: ');
  44.   GotoXY(52,13); Write('Num Lock: ');
  45.   GotoXY(64,13); Write('Scroll Lock: ');
  46.  
  47.   GotoXY(31,7); Write('<Last key pressed: >');
  48.  
  49.   FlushKey; { Empty any waiting keystrokes from the typeahead buffer }
  50.   REPEAT
  51.     Ready := GetKey(Ch,Extended,Scan,Shifts);
  52.     GotoXY(29,8);
  53.     IF Ready THEN  { If a character key has been pressed... }
  54.       IF Extended THEN Write('Extended; Scan code = ',Scan)
  55.         ELSE Write('           ',Ch,'              ');
  56.     GotoXY(17,18); IF (Shifts AND $02) <> 0 THEN   { Left Shift }
  57.       Write(Chr(31)) ELSE Write(Chr(30));
  58.     GotoXY(62,18); IF (Shifts AND $01) <> 0 THEN   { Right Shift }
  59.       Write(Chr(31)) ELSE Write(Chr(30));
  60.     GotoXY(18,17); IF (Shifts AND $04) <> 0 THEN   { Ctrl }
  61.       Write(Chr(31)) ELSE Write(Chr(30));
  62.     GotoXY(18,19); IF (Shifts AND $08) <> 0 THEN   { Alt }
  63.       Write(Chr(31)) ELSE Write(Chr(30));
  64.  
  65.     GotoXY(61,19); IF (Shifts AND $40) <> 0 THEN   { Caps Lock }
  66.       Write(Chr(15)) ELSE Write(' ');
  67.     GotoXY(72,19); IF (Shifts AND $80) <> 0 THEN   { Insert }
  68.       Write(Chr(15)) ELSE Write(' ');
  69.     GotoXY(62,13); IF (Shifts AND $20) <> 0 THEN   { Num Lock }
  70.       Write(Chr(15)) ELSE Write(' ');
  71.     GotoXY(77,13); IF (Shifts AND $10) <> 0 THEN   { Scroll Lock }
  72.       Write(Chr(15)) ELSE Write(' ');
  73.  
  74.   UNTIL Ch = Chr(27);      { Until you press ESC... }
  75.   TextMode(3);             { ...then restore cursor and quit. }
  76. END.
  77.